
var List = []                        //√
import Mock from 'mockjs'
// import { config } from 'vue/types/umd'
import { param2Obj } from "@/utils/urlUtils"

// 数据渲染
for (var i = 0; i < 100; i++) {                                  //√
    List.push({                                                 //√
        id: Mock.mock('@guid()'),
        num: Mock.mock('@natural'),
        name: Mock.mock('@cname()'),
        biaoti: '幼儿英语课程',
        money: ` $ ${Mock.mock('@float(2000, 5000, 2,2)')}`,
        moneygood: '待支付',
        time: Mock.mock('@datetime()'),
    })                                          //√
}                                       //√
export default {


    //数据渲染+分页//√
    getHomeData: config => {                //√
        console.log('config', param2Obj(config.url));
        var { KW, page, pageSize } = param2Obj(config.url)
        var res = List.filter(item => item.name.indexOf(KW) != -1)
        var resLimit = res.filter((item, index) => {
            return (page - 1) * pageSize <= index && index < page * pageSize
        })
        return {                        //√
            code: 200,                  //√
            msg: '请求成功',             //√
            data: resLimit,
            total: List.length,        //√
        }
    },


    //批量删除
    batchDeleData: config => {      //√
        var { ids } = JSON.parse(config.body)
        var res = List.filter(item => !ids.includes(item.id))
        List = res
        return {        //√
            code: 200,      //√
            msg: '批量删OK',        //√
            data: null       //√
        }
    },



}